package com.example.demo01.controller;

import com.example.demo01.utils.FileUploadUtils; // 确保导入的是你期望的类

import com.example.demo01.entity.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
@Tag(name = "文件上传")
public class FileUploadController {

    @Autowired
    private FileUploadUtils fileUploadUtils;

    /**
     * 头像上传
     *
     * @param file
     * @return
     */
    @PostMapping("/upload/avatar")
    @Operation(summary = "头像上传", description = "头像上传")
    public Result uploadAvatar(@RequestParam("file") MultipartFile file) {
        return fileUploadUtils.uploadAvatar(file);
    }

}